package com.etc.admin.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etc.admin.dao.BookRoomShowMapper;
import com.etc.admin.dao.OrderMapper;
import com.etc.admin.dao.RoomMapper;
import com.etc.admin.service.BookRoomShowService;
import com.etc.entity.BookRoomShow;
import com.etc.entity.Room;
@Service("BookRoomShowService")
public class BookRoomShowServiceImpl implements BookRoomShowService {
	@Resource
	private BookRoomShowMapper brs;
	@Resource
	private OrderMapper orderMapper;
	@Resource
	private RoomMapper roomMapper;

	@Override
	public List<BookRoomShow> getCurentOrders() {
		List<BookRoomShow> list=brs.getCurentOrders();
		for (BookRoomShow bookRoomShow : list) {
			Integer orderid=bookRoomShow.getOrderid();
			if(orderid!=null) {
			int roomstatus=orderMapper.selectByPrimaryKey(orderid).getOrderstatus();
			System.out.println(orderMapper.selectByPrimaryKey(orderid));//将当天得到的订单的状态修改为房间的状态
			int roomno=bookRoomShow.getRoomno();//得到当前的房间号，通过房间号，去修改房间的状态
			roomMapper.upStatusByRoomno(roomno, roomstatus);
			}
		}
		
		return brs.getCurentOrders();
	}

	@Override
	public List<Room> getRoomByTime(String orderstartdate, String orderenedate, int roomtype) {
		// TODO Auto-generated method stub
		return brs.getRoomByTime(orderstartdate, orderenedate, roomtype);
	}

}
